package com.lz.repository.lg.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.lz.entity.Bank;
import com.lz.entity.MortgageSheet;
import com.lz.repository.lg.MortgageSheetDaolg;
@Repository
public class MortgageSheetDaoImpllg implements MortgageSheetDaolg {

	@Override
	public Integer saveBank(Session session, Bank bank) {
		return (Integer)session.save(bank);
	}

	@Override
	public Integer saveMortgageSheet(Session session, MortgageSheet mortgageSheet) {
		return (Integer)session.save(mortgageSheet);
	}

	
	@Override
	public Integer rows(Session session,String hql) {
		Query query = session.createQuery(hql);
		List list = query.list();
		return list.size();
	}

	@Override
	public List<MortgageSheet> selectMortgageList(Session session, String hql, Integer pageNo, Integer pageSize) {
		Query query = session.createQuery(hql);
		query.setFirstResult((pageNo-1)*pageSize);
		query.setMaxResults(pageSize);
		return query.list();
	}

	@Override
	public MortgageSheet selectByPK(Session session, Integer MortgageSheetNo) {
		MortgageSheet mortgageSheet = (MortgageSheet)session.get(MortgageSheet.class, MortgageSheetNo);
		return mortgageSheet;
	}

}
